<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		 <meta http-equiv="X-UA-Compatible" content="IE=edge">
         <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
         <link rel="stylesheet" href="../assets/css/layui.css?t=1542630986934"">
         <link rel="stylesheet" href="../assets/css/view.css"/>
         <link rel="icon" href="/favicon.ico">
         <link rel="stylesheet" type="text/css" href="../assets/css/layui.css"/>
         <script src="../assets/layui.all.js" type="text/javascript" charset="utf-8"></script>
		<title></title>
		<link rel="stylesheet" type="text/css" href="../js/bootstarp-3.3.7/css/bootstrap.min.css" />
		    <script src="../vendor/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		    <script src="../js/jquery-3.2.0.min.js" type="text/javascript" charset="utf-8"></script>
		    <link rel="stylesheet" type="text/css" href="../js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		    <script src="../js/bootstarp-3.3.7/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		    <script src="../js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		    <script src="../js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
     <script>
			$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
				$.ajaxSetup({
					crossDomain: true,
					xhrFields: {
						withCredentials: true
					}
				});
			});
		</script>
         
     	  <script type="text/javascript">
     		$(function(){
     			$("#table").bootstrapTable({
     				type:"post",
					url: "http://127.0.0.1:8099/kccx/getAllInventory",
					pagination:true,
					pageSize:5, 
					queryParams:queryParam,
					columns: [{
						field: 'inventory_id',
						title: '序号',
						align: 'center',

					},{
						field: 'medicines_name',
						title: '药品名称',
						align: 'center',

					},{
						field: 'conversion',
						title: '规格',
						align: 'center',

					},{
						field: 'producter',
						title: '生产厂家',
						align: 'center',

					},{
						field: 'medicines_class',
						title: '药品分类',
						align: 'center',
 
					},{
						field: 'inventory_num',
						title: '库存',
						align: 'center',
						formatter:function (value,row,index){
						 var a =""	;					
						if(value<=row.early_warning){							
                         var a = '<span style="color:#c12e2a;">	<i class="fa fa-times-circle-o" aria-hidden="true"></i>'+value+'</span>';  
					    
						}else if(value>row.early_warning){
							       var a = '<span style="color:#3e8f3e"><i class="fa fa-check-circle-o" aria-hidden="true"></i>'+value+'</span>';  

						}
						return a;
						
						},
						
					},{
						field: 'inventory_trade_price',
						title: '批发价',
						align: 'center',

					},{
						field: 'inventory_prescription_price',
						title: '处方价',
						align: 'center',

					},{
						field: 'inventory_trade_total_amount',
						title: '批发额',
						align: 'center',

					},{
						field: 'inventory_prescription_total_amount',
						title: '处方额',
						align: 'center',

					},{
                        field: 'inventory_id',
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button  class="layui-btn layui-btn-blue" onclick="del(' + row.inventory_id + ')">调价</button>'
						}
						 
        	       }
					]
					
     			})
     			
     		   $('#btn').on('click',function(){
                    window.location.href="stock.html";
               })
               $('#btn2').on('click',function(){
                    window.location.href="stock1.html";
               })
			    
			 
     			
     			
     			
     		
               
     		})
     		function queryParam() {  
             
               return{
               	 'medicines_name':$("#medicines_name").val(),
               }
               
     		}	
     		
      		function sel () {    			
     			$("table").bootstrapTable('refresh');
     			
     		}
      		
            function del (inventory_id) {
            	 $("#mModal").modal('show');
            	 $.ajax({
					type:"post",
					url:"http://127.0.0.1:8099/kccx/selid",
				    data:"inventory_id="+inventory_id,
				    success:function(data) {
				    	/*alert(data);*/
				    	$("#medicines_nam").val(data.medicines_name);				    	
     					$("#inventory_trade_pric").val(data.inventory_trade_price);
     					$("#inventory_prescription_pric").val(data.inventory_prescription_price);
     					$("#inventory_nu").val(data.inventory_num);
     					$("#inventory_id").val(data.inventory_id);
     					
     					
				    }
				});
            }
            
            
            function queren () {
     	     var sss= $("#inventory_id").val();
     	     var cou = $("#inventory_nu").val();
     	     var cf= $("#inventory_prescription_pric").val();
     	    <!-- alert(cou);-->
     	    <!-- alert(cf);-->
     	     var zj = cou*cf;
     	     <!--alert(zj);-->
     		$.ajax({ 
     		 		type:"post",
     		 		url:"http://127.0.0.1:8099/kccx/updS",
     		 		data:$("#for1").serialize()+"&inventory_id="+sss+"&inventory_prescription_total_amount="+zj,
     		 		success:function (data) {
     		 		$("#mModal").modal('hide');
        		    $("#table").bootstrapTable('refresh');
        		  
        	      } 
     		 	});
     	}
            
      		function yj () {
      			$("#modall").modal('show');
      		}
      		
      		
      		
      		function sz () { 
      			
              $.ajax({
                	type:"post",
                	url:"http://127.0.0.1:8099/kccx/updC",
                	data:"early_warning="+$("#early_warning").val(),
                	success:function(data){
     					$("#modall").modal('hide');
     					$("#table").bootstrapTable('refresh');
	  
     				} 
                });
      		}
      		 
      		
      		
     		
          </script>
	</head>
	<body class="layui-view-body">
		<div class="layui-content">
           
        <div class="layui-row">

  	<table align="center">
  		<tr>
  			<td><button type="button" class="layui-btn layui-btn-blue"  id="btn" style=" width: 250px; display:block;margin:0 auto">药品总库存</button></td>
  			<td><button type="button" class="layui-btn layui-btn-blue"  id="btn2" style=" width: 250px; display:block;margin:0 auto">批次库存及价格</button></td>
  		</tr>
  	</table>
        	
        <div class="layui-card">
                <div class="layui-card-body">			 
                    <div class="form-box">
                        <div class="layui-form layui-form-item">
                            <div class="layui-inline">
                            
                                <div class="layui-form-mid">药品名称:</div>
                                <div class="layui-input-inline" style="width: 100px;">
                                  <input type="text" id="medicines_name"  autocomplete="off" class="layui-input" oninput="sel()" >
                                </div>                              
                                                  
  	<table align="center">
  		<tr>
  			<td width="1100px"></td>
  			<td><button type="button" style="display:block;margin:0 auto" onclick="yj()" class="layui-btn layui-btn-normal" >预警设置</button></td>
  		</tr>
  	</table>
                            </div>
                        </div>                      
                    </div> 
                </div>
                
                
                
                
                
            </div>
        </div>
    </div>
		
<!--调价-->		
		   <!-- Modal -->
<div class="modal fade" id="mModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="text-align: center;">调整处方价 </h4>
      </div>
      <div class="modal-body">
      	 <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="form-box">
                        <div class="layui-form layui-form-item">
                            <div class="layui-inline">
                            	<form id="for1">
                            		<input type="hidden" id="inventory_id" value="" />
                            		<!--<input type="hidden" id="inventory_prescription_price" value="" />-->
                                <div class="layui-form-mid">药品名称:</div>
                                <div class="layui-input-inline" style="width: 400px;">
                                  <input type="text" id="medicines_nam" name="medicines_name" autocomplete="off" class="layui-input" disabled>
                                </div> 
                                <div class="layui-form-mid">批发价:</div>
                                <div class="layui-input-inline" style="width: 415px;">
                                  <input type="text" id="inventory_trade_pric" name="inventory_trade_price" autocomplete="off" class="layui-input" disabled>
                                </div>  
                                <div class="layui-form-mid">处方价:</div>
                                <div class="layui-input-inline" style="width: 415px;">
                                  <input type="text" id="inventory_prescription_pric" name="inventory_prescription_price" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid">库存数量:</div>
                                <div class="layui-input-inline" style="width: 400px;">
                                  <input type="text" id="inventory_nu" name="inventory_num" autocomplete="off" class="layui-input" disabled>
                                </div>                                               
                               <div>
                                <button type="button"  style="display:block;margin:0 auto" onclick="queren()" class="layui-btn layui-btn-blue" >确认</button>                    
                               </div>
                            	</form>
                            </div>
                        </div>                    
                    </div> 
                </div>
                
                
                
                
                
            </div>
        </div>
    <!--   <table id="tab1"></table>-->
      </div>
      <div class="modal-footer">
       <!-- <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary">提交</button>-->
      </div>
    </div>
  </div>
</div>

<!--预警设置-->
   <!-- Small modal -->
<div class="modal fade" id="modall" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="text-align: center;">库存预警 </h4>
      </div>
      <div class="modal-body">
      	 <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="form-box">
                        <div class="layui-form layui-form-item">
                            <div class="layui-inline">
                            	<form id="for1">
                            		
                                <div class="layui-form-mid">预警数量:</div>
                                <div class="layui-input-inline" style="width: 400px;">
                                  <input type="text" id="early_warning" autocomplete="off" class="layui-input">
                                </div> 
                           
                            	</form>
                            </div>
                        </div>                    
                    </div> 
                </div>
                
                
                
                
                
            </div>
        </div>
    
      </div>
      <div class="modal-footer">
        <button type="button" onclick="sz()" class="btn btn-primary">保存</button>
      </div>
    </div>
  </div>
</div>




		
		  <table id="table"></table>
		 
		  
		  
		  
     <script src="../assets/layui.all.js"></script> 
     <script>
      var element = layui.element;
      var table = layui.table;
      var form = layui.form;
   

    </script>
	</body>
</html>
